﻿/*===============================================================================
	TASK 1a :                                           {Multidimentional Arrays}
	Write a program that fills and prints a matrix of size (n, n) as shown below:
    Example for n = 4
 
           1 5  9 13
           2 6 10 14 
           3 7 11 15
           4 8 12 16
================================================================================*/

using System;

class Matrix
{
    static void Main()
    {
//=======================================================================
//                       FIRST SOLUTION
//=======================================================================
        //Console.Write("Enter n");
        //int n = int.Parse(Console.ReadLine());

        int n = 10;

        int[,] matrix = new int[n, n];

        for (int row = 0; row < n; row++)
        {
            matrix[row, 0] = row + 1;

            for (int col = 1; col < n; col++)
            {
                matrix[row, col] = matrix[row, col - 1] + n;
            }
        }

//=======================================================================
//                       SECOND SOLUTION
//=======================================================================

        //int n = 5;
        //int[,] matrix = new int[n, n];
        //matrix[0, 0] = 1;

        //for (int col = 0; col < n; col++)
        //{
        //    for (int row = 1; row < n; row++)
        //    {
        //        matrix[row, col] = matrix[row - 1, col] + 1;
        //    }
        //    if (col == n - 1)
        //    {
        //        break;
        //    }
        //    matrix[0, col + 1] = matrix[n - 1, col] + 1;
        //}

//=======================================================================
//                       THIRD SOLUTION
//=======================================================================

        //int n = 4;
        //int[,] matrix = new int[n, n];
        //int counter = 1;

        //for (int col = 0; col < n; col++)
        //{
        //    for (int row = 0; row < n; row++)
        //    {
        //        matrix[row, col] =counter++;
        //    }
        //}

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                Console.Write(matrix[i, j] + " ");
            }
            Console.WriteLine();
        }
    }
}

